<template>
	<div>
		<el-row :gutter="24">
			<el-col :span="24">
				<el-row :gutter="24">
					<el-col :span="1" style="margin-right: 10px;">
						<p class="queryLabel">保险公司:</p>
					</el-col>
					<el-col :span="4">
						<el-select size="small" v-model="condition.insuranceCompany" placeholder="请选择保险公司" clearable>
							<el-option v-for="item in queryActiveCombo" :label="item.insuranceCompanyName" :value="item.id"></el-option>
						</el-select>
					</el-col>
					<el-col :span="1" :offset="1" style="margin-right: 10px;">
						<p class="queryLabel">结算日期:</p>
					</el-col>
					<el-col :span="9">
						<el-date-picker size="small" style="width: 150px;" v-model="condition.blanceStartDate" format="yyyy-MM-dd" :editable=false type="date" placeholder="起始日期">
						</el-date-picker>
						至
						<el-date-picker size="small" style="width: 150px;" v-model="condition.blanceStopDate" format="yyyy-MM-dd" :editable=false type="date" placeholder="结束日期">
						</el-date-picker>
					</el-col>
					<el-col :span="4">
						<el-button type="primary" size="small" v-on:click='listQuery'>查询</el-button>
					</el-col>
				</el-row>
				<el-row :gutter="24">
					<el-col :span="1" style="margin-right: 10px;">
						<p class="queryLabel">选择模板:</p>
					</el-col>
					<el-col :span="4">
						<el-select size="small" v-model="upData.schemeId" placeholder="请选择导入模板" clearable @change="tempChange">
							<el-option v-for="item in insCompayModel" :label="item.schemeTitle" :value="item.id"></el-option>
						</el-select>
					</el-col>
					<el-col :span="4">
						<div v-if="upData.schemeId != ''&&upData.billId != '' " style="clear: both;float: left">
							<el-upload :action="action" :data="upData" name="upExecl" :on-progress="process" :on-error="error" :on-success="success">
								<el-button size="small" type="primary">导入</el-button>
								<span slot="tip">只能上传xls/xlsx文件</span>
							</el-upload>
						</div>
					</el-col>

					<el-col :span="15" style="text-align: right;float:right">
						<el-button type="primary" size="small" v-on:click='addList' style="margin-left:100px;">新增</el-button>
						<el-button type="primary" size="small" v-on:click='balance'>结算</el-button>
						<el-button type="primary" size="small" v-if="billId" v-on:click='clearDetail'>清除明细</el-button>
						<el-button type="primary" size="small" v-on:click='deleteBalanceOrder'>删除对账单</el-button>
					</el-col>
				</el-row>
			</el-col>
		</el-row>

		<el-tabs v-model="activeName" @tab-click="handleClick">
			<el-tab-pane label="公司列表" name="first">

				<el-row>
					<el-col :span="24">
						<el-table :data="tableListData.dataList" border style="width: 100%;align-content: center;" @selection-change="handleSelectionChange">
							<el-table-column type="selection" width="60">
							</el-table-column>
							<el-table-column label="保险公司" prop="insuranceCompanyName">
							</el-table-column>
							<el-table-column label="结算日期" align="right" prop="blanceDate">
							</el-table-column>
							<el-table-column label="总金额" align="right" prop="totalAmount">
							</el-table-column>
							<el-table-column label="保单数" align="right" prop="insuranceTotal">
							</el-table-column>
							<el-table-column label="状态" align="right" prop="blanceType" :formatter="convertBalanceType">
							</el-table-column>
							<el-table-column label="创建日期" align="right" prop="createTime">
							</el-table-column>
							<el-table-column label="操作" align="right" prop="">
								<template scope="scope">
									<el-tooltip effect="light" content="查看明细" placement="top">
										<el-button type="primary" size="small" icon="d-arrow-right" @click.native.prevent="info(scope.$index)"></el-button>
									</el-tooltip>
								</template>
							</el-table-column>
						</el-table>
						<el-pagination small @current-change="handleCurrentChange" :current-page="CurentPage" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout=" total,prev, pager, next" :total="tableListData.total">
						</el-pagination>
					</el-col>
				</el-row>
			</el-tab-pane>
			<el-tab-pane label="对账单明细查询" name="second" @tab-click="mxQuery">
				<el-row :gutter="24">
					<el-col :span="6">
						<el-checkbox v-model="selectData.plate_num">车牌号</el-checkbox>
						<el-checkbox v-model="selectData.vin">车架号</el-checkbox>
						<el-checkbox v-model="selectData.insurance">被保险人</el-checkbox>
					</el-col>
					<el-col :span="3">
						<el-button size="small" type="primary" @click="mxQuery">查询</el-button>
						<el-button size="small" type="primary" @click="mxExport" v-loading.fullscreen.lock="fullscreenLoading">导出</el-button>
					</el-col>
					<el-col :span="15" style="font-size: 15px;">
						单交强：{{jq.total}}个&nbsp;&nbsp;单交强佣金：{{jq.poundagePrice}}元&nbsp;&nbsp;单交强保费：{{jq.price}}元&nbsp;&nbsp;<br>单商业：{{sy.total}}个 &nbsp;&nbsp;单商业佣金：{{sy.poundagePrice}}元&nbsp;&nbsp;单商业保费：{{sy.price}}元 &nbsp;&nbsp;<br>合计保单：{{all.total}}个 &nbsp;&nbsp;总保费：{{all.syPrice}}元 &nbsp;&nbsp;总佣金：{{all.syPoundagePrice}}元
					</el-col>
				</el-row>
				<el-row>
					<el-table :data="tableData.dataList" border>
						<el-table-column label="交强险出单日期"prop="jqOutOrderDate" width="130"></el-table-column>
						<el-table-column label="交强险保单号"prop="jqContractNo" width="120"></el-table-column>
						<el-table-column label="交强险保费"prop="jqPrice" width="120"></el-table-column>
						<el-table-column label="交强险佣金比率"prop="jqPoundage" width="130"></el-table-column>
						<el-table-column label="交强险佣金"prop="jqPoundagePrice" width="120"></el-table-column>
						<el-table-column label="交强险结算状态"prop="jqBlanceType" width="130" :formatter="jqCov"></el-table-column>
						<el-table-column label="商业险出单日期"prop="syOutOrderDate" width="130"></el-table-column>
						<el-table-column label="商业险保单号"prop="syContractNo" width="120"></el-table-column>
						<el-table-column label="商业险保费"prop="syPrice" width="120"></el-table-column>
						<el-table-column label="商业险佣金比率"prop="syPoundage" width="130"></el-table-column>
						<el-table-column label="商业险佣金"prop="syPoundagePrice" width="120"></el-table-column>
						<el-table-column label="商业险结算状态"prop="syBlanceType" width="130" :formatter="syCov"></el-table-column>
					</el-table>
					<el-pagination small @current-change="handleCurrentChanges" :current-page="CurentPages" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout=" total,prev, pager, next" :total="tableData.total">
						</el-pagination>
				</el-row>
			</el-tab-pane>
		</el-tabs>

		<el-dialog title="新增对账单" v-model="listFormShow" size="tiny">
			<el-form :model="addDate" ref="comForm" :rules="listRule" label-width="150px">
				<el-col :span="24">
					<el-form-item label="保险公司：" prop="insuranceCompanyId" required>
						<el-select size="small" style="width: 100%;" v-model="addDate.insuranceCompanyId" placeholder="请选择保险公司" clearable>
							<el-option v-for="item in queryActiveCombo" :label="item.insuranceCompanyName" :value="item.id"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="结算开始日期：" prop="blanceStartDate" required>
						<el-date-picker style="width: 95%;" v-model="addDate.blanceStartDate" size="small" format="yyyy-MM-dd" :editable=false type="date" placeholder="结算日期">
						</el-date-picker>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="结算结束日期：" prop="blanceStopDate" required>
						<el-date-picker style="width: 95%;" v-model="addDate.blanceStopDate" size="small" format="yyyy-MM-dd" :editable=false type="date" placeholder="结算日期">
						</el-date-picker>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="是否含税：" prop="inTax" required>
						<el-select size="small" style="width: 100%;" v-model="addDate.inTax" placeholder="请选择保险公司" clearable>
							<el-option label="包含" value="1"></el-option>
							<el-option label="不包含" value="0"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="24" v-if="addDate.inTax =='0'">
					<el-form-item label="税率：" prop="tax" required>
						<el-input size="small" :maxlength="200" v-model="addDate.tax" type="number">
							<template slot="append">%</template>
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					
				</el-col>
				<!--<el-col :span="24">
					<el-form-item label="保单数：" prop="totalAmount">
						<el-input-number v-model="addDate.totalAmount" :min="1"></el-input-number>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="保险佣金：(%)" prop="insuranceCommission">
						<el-input-number v-model="addDate.insuranceCommission" :min="0" :max="100" :step="0.01"></el-input-number>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="总金额：(￥)" prop="insuranceTotal">
						<el-input-number v-model="addDate.insuranceTotal" :min="0"></el-input-number>
					</el-form-item>
				</el-col>-->
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="listFormShow = false">取 消</el-button>
				<el-button type="primary" v-on:click='saveList'>提 交</el-button>
			</div>
		</el-dialog>
		<el-dialog title="结算" v-model="balanceShow" size="tiny">
			<el-form :model="balanceCondition" ref="comForms" :rules="listRules" label-width="150px">
				<el-col :span="24">
						<el-form-item label="选择区域：" required>
							<el-select size="small" v-model="balanceCondition.area" style="width: 100%;" @change="getCompanyInfo" placeholder="请选择区域" clearable>
								<el-option v-for="item in areaCombo" :label="item.label" :value="item.code"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
				<el-col :span="24">
					<el-form-item label="应用单位：" prop="carCompany">
						<el-select size="small" v-model="balanceCondition.carCompany" style="width: 100%;" placeholder="请选择单位" clearable multiple>
							<el-option v-for="item in applyUnitCombo" :label="item.oName" :value="item.id"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="结算规则：" prop="balance">
						<el-select v-model="balanceCondition.balance" size="small" style="width: 100%;" placeholder="请选择结算规则" clearable>
							<el-option label="出单日期" value="0"></el-option>
							<el-option label="起保日期" value="1"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="开始日期：" prop="startDate">
						<el-date-picker v-model="balanceCondition.startDate" style="width: 95%;" size="small" format="yyyy-MM-dd" :editable=false type="date" placeholder="开始日期">
						</el-date-picker>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="结束日期：" prop="stopDate">
						<el-date-picker v-model="balanceCondition.stopDate" style="width: 95%;" size="small" format="yyyy-MM-dd" :editable=false type="date" placeholder="结束日期">
						</el-date-picker>
					</el-form-item>
				</el-col>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="balanceShow = false">取 消</el-button>
				<el-button type="primary" v-on:click='submitBalance'>提 交</el-button>
			</div>
		</el-dialog>
	</div>
</template>

<script>
	import moment from 'moment'
	export default {
		data: function() {
			return {
				//区域
				areaCombo:[],
				//对账单明细查询条件
				selectData: {
					plate_num: true,
					vin: false,
					insurance: true,
				},
				//对账单明细查询接收数据
				all:{},
				jq:{},
				sy:{},
				tableData:{
					total:0,
					dataList:[]
				},
				//等待框
				fullscreenLoading: false,
				dataList:[],
				action: this.API_ROOT + "/insurance/company/bill/upload",
				upData: {
					schemeId: '', //模板id
					uid: window.localStorage.getItem("uid"),
					token: window.localStorage.getItem("token"),
					billId: '', //这一行的id
				},
				//页码数
				CurentPage: 1,
				CurentPages: 1,
				//每页的数量
				page: this.page,
				isMultiple: true,
				listFormShow: false, //公司列表新增弹框
				balanceShow: false, //结算
				multipleSelection: [], //公司列表的checkbox选择数据
				multipleSelectiondetail: [], //明细的checkbox选择数据
				queryActiveCombo: [], //保险公司查询数据
				insCompayModel: [], //保险公司模板下拉数据
				applyUnitCombo: [], //查询的应用单位数据
				billId: '', //点击查看明细时这一行的id
				condition: { //查询条件
					insuranceCompany: '',
					blanceStartDate: '',
					blanceStopDate: ''
				},
				balanceCondition: { //结算条件
					area:"",//区域
					carCompany: [], //公司
					balance: '', //结算规则
					startDate: '', //开始时间
					stopDate: '', //结束时间
				},
				balanceConditionEmpty: { //结算条件
					carCompany: [], //公司
					balance: '', //结算规则
					startDate: '', //开始时间
					stopDate: '', //结束时间
				},
				addDate: {
					insuranceCompanyId: "", //保险公司id
					insuranceCommission: "", //保险佣金
					blanceStartDate: "", //结算开始日期
					blanceStopDate: "", //结算结束日期
					totalAmount: "", //保单数
					insuranceTotal: "", //总金额
					inTax:"1",//是否包含税
					tax:'',//税率
				},
				addDateEmpty: {
					insuranceCompanyId: "", //保险公司id
					insuranceCommission: "", //保险佣金
					blanceStartDate: "", //结算开始日期
					blanceStopDate: "", //结算结束日期
					totalAmount: "", //保单数
					insuranceTotal: "", //总金额
					inTax:"1",//是否包含税
					tax:'',//税率
				},
				activeName: 'first', //tab切换
				tableListData: { //列表数据
					dataList: [],
					total: 0
				},
				tableDetailData: {
					dataList: [],
					total: 0
				},
				balanceFormData: {}, //结算选的数据
				listRule:{
					insuranceCompanyId: [{
						required: true,
						message: '请选择保险公司',
						trigger: 'blur'
					}],
					blanceStartDate: [{
						type: 'date',
						required: true,
						message: '请选择结算开始时间',
						trigger: 'blur'
					}],
					blanceStopDate: [{
						type: 'date',
						required: true,
						message: '请选择结算结束时间',
						trigger: 'blur'
					}],
					inTax:[{
						required: true,
						message: '请选择是否包含税',
						trigger: 'blur'
					}],
					tax:[{
						required: true,
						message: '请填写费率',
						trigger: 'blur'
					}],
//					totalAmount:[{
//						required: true,
//						message: '请填写保单数',
//						trigger: 'blur'
//					}],
//					insuranceCommission:[{
//						required: true,
//						message: '请填写保险佣金',
//						trigger: 'blur'
//					}],
//					insuranceTotal:[{
//						required: true,
//						message: '请填写总金额',
//						trigger: 'blur'
//					}],
				},
				listRules:{
					area: [{
						required: true,
						message: '请选择区域',
						trigger: 'blur'
					}],
					carCompany: [{
						type: 'array',
						required: true,
						message: '请选择保险公司',
						trigger: 'blur'
					}],
					startDate: [{
						type: 'date',
						required: true,
						message: '请选择结算开始时间',
						trigger: 'blur'
					}],
					stopDate: [{
						type: 'date',
						required: true,
						message: '请选择结算结束时间',
						trigger: 'blur'
					}],
					balance:[{
						required: true,
						message: '请填写保单数',
						trigger: 'blur'
					}],
				},
			}
		},
		methods: {
			//转换标签页触发方法
			handleClick: function(){
				if(this.$data.activeName == "first"){
					this.$data.tableData.dataList = [];//明细界面表单数据
					this.$data.tableData.total = 0;//明细界面分页
					this.$data.billId = "";//清空对账单ID
				}
			},
			//明细查询
			mxQuery: function() {
				this.$http.post(this.API_ROOT + '/insurance/company/bill/billDetail', this.$data.selectData, {
					params: {
						billId: this.$data.billId,
						start : this.$data.CurentPages,
						limit: this.page.pageSize,
					}
				}).then(resp => {
					debugger;
					if(resp.data.success) {
						resp.data.total = parseInt(resp.data.total);
						this.$data.tableData.dataList = resp.data.dataList;
						this.$data.tableData.total = resp.data.total;
						this.$data.all = resp.data.all;
						this.$data.jq = resp.data.jq;
						this.$data.sy = resp.data.sy;
					} else {
						//debugger;
						this.$message.error(resp.data.msg);
					}
				}, resp => {});

			},
			//明细导出
			mxExport: function() {
				debugger;
				this.$data.fullscreenLoading = true;
				this.$http.post(this.API_ROOT + '/insurance/company/bill/billDetail/exp/excel', this.$data.selectData, {
						params: {
							billId:this.$data.billId,
						}
					})
					.then(resp => {
						if(resp.data.success) {
							debugger;
							window.location.href = this.API_ROOT + "/base/exp/xlsx?fileId=" + resp.data.data + "&&fileName=明细报表-" + this.moment().format("YYYYMMDDHHmmss") + "&&fileType=xlsx";
						
						}
						this.$data.fullscreenLoading = false;
					}, resp => {});
			},
			//查看明细
			info: function(index) {
				this.$data.billId = this.$data.tableListData.dataList[index].id;
				debugger;
				this.mxQuery();
				this.$data.activeName = "second";
			},
			//列表查询
			listQuery: function() {
				this.$http.post(this.API_ROOT + '/insurance/company/bill/page', this.$data.condition, {
					params: {}
				}).then(resp => {
					debugger;
					if(resp.data.success) {
						resp.data.data.total = parseInt(resp.data.data.total);
						this.$data.tableListData = resp.data.data;
						
					} else {
						//debugger;
						this.$message.error(resp.data.msg);
					}
				}, resp => {});
			},
			//明细查询
			queryDetail: function() {
				this.$http.get(this.API_ROOT + '/insurance/company/bill/billDetail', {
					params: {
						billId: this.$data.billId,
						start: this.$data.CurentPages,
						limit: this.page.pageSize
					}
				}).then(resp => {
					debugger;
					if(resp.data.success) {
						resp.data.data.total = parseInt(resp.data.data.total);
						this.$data.tableDetailData = resp.data.data;
					} else {
						//debugger;
						this.$message.error(resp.data.msg);
					}
				}, resp => {});
			},
			//新增
			addList: function() {
				debugger;
				this.$data.addDate = Object.assign(this.$data.addDate, this.$data.addDateEmpty);
				this.$data.listFormShow = true;
			},
			//保存公司列表
			saveList: function() {
				this.$refs.comForm.validate(function(valid, $event) {
					// 验证通过
					if(valid) {
						debugger;
						this.$data.addDate.blanceStartDate = moment(this.$data.addDate.blanceStartDate).format("YYYY-MM-DD");
						this.$data.addDate.blanceStopDate = moment(this.$data.addDate.blanceStopDate).format("YYYY-MM-DD");
						this.$http.post(this.API_ROOT + '/insurance/company/bill/save', this.$data.addDate)
							.then(resp => {
								if(resp.data.success) {
									debugger;
									this.listQuery();
									this.$data.listFormShow = false;
									this.$message(resp.data.msg);
								} else {
									this.$message.error(resp.data.msg);
								}
							}, resp => {

							});
					} else {
						return false
					}
				}.bind(this))
			},

			//清除明细
			clearDetail: function() {
				this.$confirm('此操作将清除该明细数据, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$http.get(this.API_ROOT + '/insurance/company/bill/moveBillDetail', {
						params: {
							billId: this.$data.billId
						}
					}).then(resp => {
						debugger;
						if(resp.data.success) {
							this.mxQuery();
							this.$message(resp.data.msg);
						} else {
							//debugger;
							this.$message.error(resp.data.msg);
						}
					}, resp => {});

				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消清除'
					});
				});
			},
			//删除对账单
			deleteBalanceOrder: function() {
				if(this.$data.multipleSelection.length == 1) {
					this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					}).then(() => {
						this.$http.get(this.API_ROOT + '/insurance/company/bill/del', {
							params: {
								billId: this.$data.multipleSelection[0].id
							}
						}).then(resp => {
							debugger;
							if(resp.data.success) {
								this.listQuery();
								this.$message(resp.data.msg);
							} else {
								//debugger;
								this.$message.error(resp.data.msg);
							}
						}, resp => {});
					}).catch(() => {
						this.$message({
							type: 'info',
							message: '已取消删除'
						});
					});

				} else {
					this.$message.error("请选择一条数据")
				}
			},
			//结算
			balance: function() { //TODO
				if(this.$data.multipleSelection.length == 1) {
					this.$data.balanceShow = true;
					this.$data.balanceCondition = Object.assign(this.$data.balanceCondition, this.$data.balanceConditionEmpty);
				} else {
					this.$message.error("请选择一条数据")
				}

			},
			//结算保单
			submitBalance: function() {
				this.$refs.comForms.validate(function(valid, $event) {
					// 验证通过
					if(valid) {
						this.$data.balanceCondition.startDate = moment(this.$data.balanceCondition.startDate).format("YYYY-MM-DD");
						this.$data.balanceCondition.stopDate = moment(this.$data.balanceCondition.stopDate).format("YYYY-MM-DD");
						this.$http.post(this.API_ROOT + '/insurance/company/bill/balance', this.$data.balanceCondition, {
								params: {
									billId: this.$data.multipleSelection[0].id
								}
							})
							.then(resp => {
								if(resp.data.success) {
									debugger;
									this.listQuery();
									this.$data.balanceShow = false;
									this.$message(resp.data.msg);
								} else {
									this.$message.error(resp.data.msg);
								}
								this.$data.balanceCondition.startDate = new Date(this.$data.balanceCondition.startDate);
						        this.$data.balanceCondition.stopDate = new Date(this.$data.balanceCondition.stopDate);
							}, resp => {

							});
					} else {
						return false
					}
				}.bind(this))
			},
			tempChange: function(newValue) {
				window.localStorage.setItem("itemTemplate", newValue);
			},
			//选择框
			handleSelectionChange: function(val) {
				debugger;
				this.$data.multipleSelection = val;
				this.upData.billId = val[0].id;
			},
			//明细
			handleSelectionChanges: function(val) {
				debugger;
				this.$data.multipleSelectiondetail = val;
			},
			//列表,当前页切换
			handleCurrentChange: function(currentPage) {
				this.$data.CurentPage = currentPage;
				this.listQuery();
			},
			//明细,当前页切换
			handleCurrentChanges: function(currentPage) {
				debugger;
				this.$data.CurentPages = currentPage;
				this.mxQuery();
			},
			//转换结算状态
			convertBalanceType: function(row, column) {
				if(row.blanceType == '0') {
					return '未结算'
				} else if(row.blanceType == '1') {
					return '已结算'
				} else if(row.blanceType == '2') {
					return '已开票'
				}
			},
			//保险公司模板下拉查询
			queryInsCompayModel: function() {
				this.$http.get(this.API_ROOT + '/insurance/company/bill/excelCombo', {
					params: {}
				}).then((response) => {
					debugger;
					this.$data.insCompayModel = response.data.data;
				}, (response) => {
					// error callback
				});
			},
			//转换明细状态
			convertStatus: function(row, column) {
				if(row.blanceType == '0') {
					return '待结算'
				} else if(row.blanceType == '1') {
					return '已结算'
				}
			},
			convertContractTyps:function(row,column){
				if(row.contractType == 'sy'){
					return '商业险';
				}else{
					return '交强险';
				}
			},
//			//获取应用单位
//			companydata: function() {
//				debugger;
//				this.$http.get(this.API_ROOT + '/insurance/commission/carCompanys', {
//					params: {
//						area: this.$data.balanceCondition.area
//					}
//				}).then(resp => {
//					if(resp.data.success) {
//						debugger;
//						this.$data.applyUnitCombo = resp.data.data;
//					} else {
//						this.$message.error(resp.data.msg);
//					}
//				}, resp => {});
//			},
			//应用单位下拉框改变时
//			applyUnitChange: function(val) { //TODO
//				console.log(JSON.stringify(val));
//				debugger;
//				if(val == '') {
//					this.companydata();
//				}
//				for(var i = 0; i < val.length; i++) {
//					if(val[i] == '0_全部') {
//						debugger;
//						this.$data.applyUnitCombo = [{
//							id: "0_全部",
//							oName: "全部"
//						}].slice(0);
//						//                      this.$data.comFormDatas.carCompany=["0_全部"];
//						break;
//					}
//					if(val[0] != '0_全部') {
//						this.$http.get(this.API_ROOT + '/insurance/commission/carCompanys', {
//							params: {}
//						}).then(resp => {
//							if(resp.data.success) {
//								debugger;
//								this.$data.applyUnitCombo = resp.data.data.splice(1);
//								//						console.log(JSON.stringify(resp.data.data))
//							} else {
//								this.$message.error(resp.data.msg);
//							}
//						}, resp => {});
//					}
//				}
//			},
			/*--------------------------导入需要的方法-------------------------------*/
			process: function() {
				if(this.$data.multipleSelection.length == 1) {
					this.$data.loadingVue = this.$loading({
						fullscreen: true,
						text: "正在导入数据，请稍候"
					});
				} else {
					this.$message.error('请选择一条列表数据');
					this.$data.multipleSelection = [];
				}

			},
			error: function(err, response) {
				this.$message.error(response.data.msg);
				this.$data.loadingVue.close();
			},
			success: function(response) {
				this.$data.loadingVue.close();

				if(response.success) {
					this.listQuery();
					this.$message(response.msg);
				} else {
					this.$message.error(response.msg);
				}

			},
			//结算状态转换
			jqCov: function(row,column){
				if(row.jqBlanceType == 0)return "未结算";
				if(row.jqBlanceType == 1)return "已结算";
			},
			//结算状态转换
			syCov: function(row,column){
				if(row.syBlanceType == 0)return "未结算";
				if(row.syBlanceType == 1)return "已结算";
			},
			//获取区域
			getarea: function() {

				debugger;
				this.$http.get(this.API_ROOT + "/rbac/dept/area/all", {
					params: {
					}
				}).then(resp => {
					this.$data.areaCombo = resp.data.dataList;
				});
			},
			//获取公司信息
			getCompanyInfo: function() {
				//this.$data.data.companyId = ""; //清空单位
				this.$data.balanceCondition.carCompany = []; //清空单位
				this.$data.applyUnitCombo = [];
				debugger;
				this.$http.get(this.API_ROOT + "/rbac/dept/all", {
					params: {
						area: this.$data.balanceCondition.area,
					}
				}).then(resp => {
					debugger;
					this.$data.applyUnitCombo = resp.data.dataList;
				});
			},

		},
		created: function() {
			this.getarea();//获取区域
			this.listQuery(); //列表查询
			//获取保险公司下拉
			this.$http.get(this.API_ROOT + '/insurance/companys', {
				params: {}
			}).then((response) => {
				this.$data.queryActiveCombo = response.data.data;
			}, (response) => {});

			this.queryInsCompayModel();

			var temp = window.localStorage.getItem("itemTemplate");
			if(temp && temp != null && temp.length > 10) {
				debugger;
				this.$data.upData.schemeId = temp;
			};

		}
	}
</script>

<style>

</style>